import { DataTypes } from 'sequelize'
const seq = require('../db/seq')

const RegionModels: any = seq.define('region', {
  id: {
    type: DataTypes.INTEGER,
    allowNull: false,
    primaryKey: true,
    comment: "区域主键"
  },
  name: {
    type: DataTypes.STRING(255),
    allowNull: false,
    comment: "区域名称"
  },
  pid: {
    type: DataTypes.INTEGER,
    allowNull: false,
    comment: "区域上级标识"
  },
  sname: {
    type: DataTypes.STRING(40),
    allowNull: true,
    comment: "地名简称"
  },
  level: {
    type: DataTypes.INTEGER,
    allowNull: false,
    comment: "区域等级"
  },
  citycode: {
    type: DataTypes.STRING(20),
    allowNull: true,
    comment: "区域编码"
  },
  yzcode: {
    type: DataTypes.STRING(20),
    allowNull: true,
    comment: "邮政编码"
  },
  mername: {
    type: DataTypes.STRING(100),
    allowNull: true,
    comment: "组合名称"
  },
  lng: {
    type: DataTypes.FLOAT,
    allowNull: true,
    comment: "经度"
  },
  lat: {
    type: DataTypes.FLOAT,
    allowNull: true,
    comment: "纬度"
  },
  pinyin: {
    type: DataTypes.STRING(100),
    allowNull: true
  }
}, {
  tableName: 'region',
  timestamps: false,
  indexes: [
    {
      name: "PRIMARY",
      unique: true,
      using: "BTREE",
      fields: [
        { name: "id" },
      ]
    },
    {
      name: "index2",
      using: "BTREE",
      fields: [
        { name: "pid" },
      ]
    },
  ]
});

module.exports = RegionModels